In [74]:
from IPython.display import display
from IPython.display import HTML
from IPython.display import Image
import IPython.core.display as di # Example: di.display_html('<h3>%s:</h3>' % str, raw=True)

display(HTML("<style>.container { width:1600px !important; }</style>"))

# This line will hide code by default when the notebook is exported as HTML
di.display_html('<script>jQuery(function() {if (jQuery("body.notebook_app").length == 0) { jQuery(".input_area").toggle(); jQuery(".prompt").toggle();}});</script>', raw=True)

# This line will add a button to toggle visibility of code blocks, for use with the HTML export version
di.display_html('''<button onclick="jQuery('.input_area').toggle(); jQuery('.prompt').toggle();">Toggle code</button>''', raw=True)
In [75]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import re
from matplotlib.cm import get_cmap
from matplotlib import cm
import seaborn as sns

import plotly.io as pio
import plotly.express as px
import plotly.figure_factory as ff
import plotly.graph_objects as go
from plotly.subplots import make_subplots
pio.renderers.default = 'notebook'

import warnings
warnings.filterwarnings('ignore')

import math

pd.set_option('display.max_rows', 1000)
pd.set_option('display.max_columns', 1000)

London UK Airbnb Open Data¶

About Dataset:

Since 2008, guests and hosts have used Airbnb to expand on traveling possibilities and present more unique, personalized way of experiencing the world. This dataset describes the listing activity and metrics in London UK in 2022.

The follow stydy shows wich neighborhoods has been more demanded during the year 2022, who are the hosts, the price ranges and the room type

In [ ]:
df = pd.read_csv('listingss.csv')
In [77]:
nei = df.groupby(['neighbourhood'])['id'].count()

1 - Wich are the most demanded Neibourhoods in London?¶

In [78]:
px.bar(nei, height=800,width=1000).update_xaxes(categoryorder="total descending", title='Most Demanded Neighbourhoods in London during 2022')

2 - What sort of RoomTypes are demanded the most?¶

In [79]:
rt = df.groupby(['neighbourhood','room_type'])['id'].count().unstack().fillna(0)
In [80]:
px.bar(rt, height=800, width=1100).update_xaxes(categoryorder='total descending', title='Most Demanded Room Type by Neighbourhood - London 2022')
  • The same data is represented using a HeatMap
In [81]:
## HeatMap
fig, ax = plt.subplots(figsize=(10,8))
sns.heatmap(rt)
plt.show()

3 - Who are the most selected Hosts?¶

In [89]:
rev = df.groupby(['host_name'])['number_of_reviews'].count().sort_values(ascending=False).reset_index().head(30)
# rev.sort_values(by=['number_of_reviews'], ascending=False)

1 - Data Shown in Bar Graph

In [83]:
px.bar(rev, x='host_name',y='number_of_reviews', width=1000, title='Top 30 Most Demanded ABNB User-Hosts')

2 - Data Shown in Pie Graph

In [84]:
px.pie(rev)
fig = px.pie(rev, values='number_of_reviews', names='host_name', title='Top 30 Most Demanded ABNB User-Hosts in %', width=1000)
fig.show()
In [85]:
price = df.groupby(['neighbourhood','room_type'])['price'].mean().unstack().fillna(0)

# rt = df.groupby(['neighbourhood','room_type'])['id'].count().unstack().fillna(0)
# rt

4 - Wich are the most expensive Neighbourhoods ordered by RoomType?¶

In [86]:
px.bar(price, orientation='h',height=800, width=1000, title='Most Demanded Neibourhoods ordered by RoomType').update_yaxes(categoryorder='total ascending')
In [87]:
%%javascript
let customVariablesTooltip = {
"tx disruption" : "(Discontinuation, Switch from, Dose Reduction)",
"tx disruptions" : "(Discontinuation, Switch from, Dose Reduction)",
"disruption" : "(Discontinuation, Switch from, Dose Reduction)",
"event" : "(Adverse Event, Cost, Patient Preference, Efficacy, Insurance)",
"events" : "(Adverse Event, Cost, Patient Preference, Efficacy, Insurance)"
}


$(document).ready(() => {
$(".hasTooltip").each((i, element) => {
  $(element).html("<div></div>" + $(element).html());
})

$(".hasTooltip").mouseover((e) => {
  let key =  $(e.currentTarget).text().toLowerCase();

  $(e.currentTarget).find("div").removeClass()
  .addClass("tooltipContent")
  .css({"top": e.clientY,"left": e.clientX})
  .text(customVariablesTooltip[key]);
});
});
In [88]:
%%html
<style>
  .hasTooltip {
    display: inline-block;
    border-bottom: 1px solid #00857d;
    padding-bottom: 3px;
    text-align: left;
    cursor: default;
    line-height: normal;
    color: #00857d;
  }

  .hasTooltip .tooltipContent {
      padding:8px;
      color:#fff;
      background-color:#00857d;
      border-radius:3px;
      position: fixed;
      z-index:2000;
      box-sizing:border-box;
      box-shadow:0 1px 8px rgba(0,0,0,0.5);
      display:none;
      font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
      font-style: normal;
      font-weight: normal;
      letter-spacing: normal;
      line-break: auto;
      line-height: 1.42857143;
      text-align: left;
      text-align: start;
      text-decoration: none;
      text-shadow: none;
      text-transform: none;
      white-space: normal;
      word-break: normal;
      word-spacing: normal;
      word-wrap: normal;
      font-size: 12px;
      transform: translate(20px, -50%);
  }

  .hasTooltip:hover .tooltipContent {
      display: block;
  }

}
</style>
In [ ]:
 
In [ ]: